package com.management.department.teacherinfosystem.Repository;

import com.management.department.teacherinfosystem.Entity.ServiceContribution;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.List;

public interface ServiceContributionRepository extends JpaRepository<ServiceContribution, Long> {
    List<ServiceContribution> findByUserId(@Param("userId") Long userId);
    List<ServiceContribution> findByStatus(@Param("status") String status);

    @Query("select s from ServiceContribution s where (:type is null or s.workType = :type) and (:status is null or s.status = :status) and (:start is null or s.createdAt >= :start) and (:end is null or s.createdAt <= :end) order by s.createdAt desc")
    List<ServiceContribution> search(@Param("type") String type, @Param("status") String status, @Param("start") Date start, @Param("end") Date end);
}


